home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1992-09-28 | 4.0 KB | 134 lines |
- '***************************
- '* AMOS Professional *
- '* *
- '* MENUS 3 *
- '* * Automatic Menu selection action
- '* (c) Europress Software *
- '* *
- '* Ronnie Simpson *
- '***************************
- '
- '-------------------------------------------
- 'When using menus with more than a few options a long list of If...Then
- 'statements would be required to cover each possible selection, AMOS
- 'Professional provides 3 instructions to avoid this and easily deal with
- 'even the largest of menus.
- '
- 'Once this feature is in action automatic menu checking is performed every
- '1/50th. of a second using inturupts and is independant of the rest of the
- 'program.
- '
- 'For all three versions the following initialisation procedure should be
- 'followed to switch on the automatic system
- '
- ' Menu$(1)=.... (define your menu or load from bank)
- ' Menu On (switch on menu)
- ' On Menu...... (define the type of action)
- ' On Menu On (switch on the automatic checking)
- '
- 'The 3 types of action are
- '
- ' On Menu Goto......
- ' On Menu Proc......
- ' On Menu Gosub.....
- '
- 'Each title in your menu is assigned its own label or procedure which is
- 'called automatically each time a selection is made:-
- '
- ' On Menu Proc TITLE1,TITLE2,TITLE3.....etc.
- '
- 'On Menu Proc... causes program control to jump to the procedure defined
- 'in the parameters when an item is selected from the menu, the procedure
- 'can now use the =Choice function to take the required action.
- 'Program control will return to the instruction following the call.
- 'Each time a Procedure is entered the automatic system is switched off and
- 'a further call to On Menu On is required before the End Proc to re-activate
- 'the automatic checking.
- '
- 'On Menu Gosub... works in exactly the same way with the exception that
- 'procedures are replaced with subroutines.
- 'Each subroutine is defined with its own label and once again On Menu On must
- 'be used before the Return instruction to re-activate the automatic checking.
- '
- 'On Menu Goto.... has been superceeded by the Proc and Gosub versions but
- 'have been included to maintain compatability.
- '
- 'If you wish to use more than one set of labels within a program
- 'On Menu Del will erase the list from memory and allow you to define
- 'a new set.
- 'Before this can be done the automatic system must be turned off:-
- '
- ' On Menu Off
- ' On Menu Del
- ' On Menu Proc FIRST,SECOND....etc.
- ' On Menu On
- '
- '-------------------------------------------
- 'WORKING EXAMPLE
- '-------------------------------------------
- '
- Dim T$(5)
- '
- Rem *** tidy up the screen
- '
- Screen Open 0,640,200,16,Hires
- Palette $0,$F00,$F0,$F,$FF0,$F0F,$FF,$9F9,$7F,$70F,$F07,$333,$666,$999,$CCC,$FFF
- Flash Off : Curs Off : Cls 0 : Pen 0 : Paper 7 : Ink 14,0
- '
- Rem *** set the menu titles
- '
- Menu$(1)=" CONTROL "
- Menu$(2)=" POINTER SHAPE "
- Menu$(3)=" COLOURS "
- '
- Rem *** set the options
- '
- Menu$(1,1)=" QUIT "
- '
- Menu$(2,1)=" POINTER "
- Menu$(2,2)=" CROSS-HAIRS "
- Menu$(2,3)=" CLOCK "
- '
- Menu$(3,1)=" RED "
- Menu$(3,2)=" GREEN "
- Menu$(3,3)=" BLUE "
- Menu$(3,4)=" YELLOW "
- Menu$(3,5)=" MAGENTA "
- Menu$(3,6)=" CYAN "
- '
- T$(1)="Press right mouse key to see the menu."
- T$(2)="Menu control is now independant of the main program."
- T$(3)="Each title has its own procedure."
- T$(4)="On Menu avoids using too many If...Then statements."
- T$(5)="Select CONTROL/QUIT from the menu to return to the editor."
- '
- Rem *** start the automatic checking
- '
- Menu On
- On Menu Proc CONTROL,MOUSE,KOLOURS
- On Menu On
- '
- Rem *** loop whilst waiting for menu
- '
- Do
- Add COUNT,1,1 To 3000
- If COUNT=500
- Add N,1,1 To 5
- Text 100,N*32,T$(N)
- End If
- Loop
- '
- Procedure CONTROL
- Edit
- End Proc
- '
- Procedure MOUSE
- Change Mouse Choice(2)
- On Menu On
- End Proc
- '
- Procedure KOLOURS
- Shared T$()
- Ink Choice(2),0
- On Menu On
- End Proc